#include <bits/stdc++.h>
// 2025/02/04
// tag: 
// Author: Zhang Muen
using namespace std;

using int64 = int64_t;

class MQueue{
private:
    deque<int> q, pos;
public:
    void push(int x, int i){
        while (!q.empty() && q.back() > x)
            q.pop_back(), pos.pop_back();
        q.push_back(x), pos.push_back(i);
    }
    void pop(int i){
        if (!pos.empty() && pos.front() <= i)
            q.pop_front(), pos.pop_front();
    }
    int get_min(){
        return q.front();
    }
    int get_max(){
        return q.back();
    }
};

int n, m, a[2000001];

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cin >> n >> m;
    MQueue q;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = 1; i <= n; i++) {
        if (i > m)
            q.pop(i - m - 1);
        cout << q.get_min() << endl;
        q.push(a[i], i);
    }
    return 0;
}